/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.additional;

import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.list.ListCellRenderer;
import datamodel.Position;


/**
 *
 * @author Kvest
 */
public class PositionListRenderer extends Container implements ListCellRenderer
{
    private Label name = new Label("");
    private Label count = new Label("");

    private Label focusComponent = new Label();

    public PositionListRenderer()
    {
        setLayout(new BorderLayout());
        addComponent(BorderLayout.WEST, name);
        addComponent(BorderLayout.EAST, count);

        name.setUIID("ListRenderer");
        count.setUIID("ListRenderer");
        setUIID("ListRenderer");
        
        focusComponent.setUIID("ListRendererFocus");
        focusComponent.setFocus(true);
    }
    
    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected)
    {     
        setFocus(isSelected);
        if (value != null && (value instanceof Position))
        {
            name.setText(((Position)value).getParkingName());
            count.setText(((Position)value).getCarsCount());
        }
        
        return this;
    }

    public Component getListFocusComponent(List list) 
    {
        return focusComponent;
    }
}
